import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/loginVue')
  },
  {
    path: '/',
    name: 'Layout',
    component: () => import('@/views/layout/layOut'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home/homeIndex')
      },
      {
        path: '/health',
        name: 'HealthEncyclo',
        component: () => import('@/views/healthEncyclo/healthEncyclo')
      },
      {
        path: '/message',
        name: 'MessageCenter',
        component: () => import('@/views/messageCenter/messageCenter')
      },
      {
        path: '/my',
        name: 'My',
        component: () => import('@/views/my/myIndex')
      }
    ]
  },
  { // 我的问诊
    path: '/consult',
    name: 'Consult',
    component: () => import('@/views/consult/consultIndex')
  },
  { // 订单详情
    path: '/my/consult/:id',
    name: 'Detail',
    component: () => import('@/views/consult/consultDetail')
  },
  { // 家庭档案 or 选择患者
    path: '/my/patient',
    name: 'Patient',
    component: () => import('@/views/patient/patientIndex')
  },
  { // 极速问诊
    path: '/consult/fast',
    name: 'Fast',
    component: () => import('@/views/consult/fastConsult')
  },
  { // 选择科室
    path: '/consult/dep',
    name: 'Dep',
    component: () => import('@/views/consult/consultDep')
  },
  { // 图文问诊
    path: '/consult/illness',
    name: 'Illness',
    component: () => import('@/views/consult/consultIllness')
  },
  { // 支付
    path: '/consult/pay/:id',
    name: 'Pay',
    component: () => import('@/views/consult/consultPay')
  },
  { // 医生问诊室
    path: '/room',
    name: 'Room',
    component: () => import('@/views/consult/consultRoom')
  },
  { // 药品支付
    path: '/order/pay',
    name: 'OrderPay',
    component: () => import('@/views/order/orderPay')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
  scrollBehavior (to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  }
})

export default router
